package com.caiden_micheal.base.utils;

import java.security.SecureRandom;

public class GenerateCodeUtil {
    public static String generateRandomString(int length) {
        SecureRandom random = new SecureRandom();
        StringBuilder sb = new StringBuilder(length);
        for (int i = 0; i < length; i++) {
            int randomInt = random.nextInt(255);
            String hex = Integer.toHexString(randomInt);
            sb.append(hex.length() == 1 ? "0" + hex : hex);
        }
        return sb.toString();
    }
}
